//package poidemo.poi;
//
//import org.apache.poi.ooxml.POIXMLDocumentPart;
//import org.apache.poi.openxml4j.opc.PackagePart;
//import org.apache.xmlbeans.XmlOptions;
//import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTComment;
//import org.openxmlformats.schemas.wordprocessingml.x2006.main.CTComments;
//import org.openxmlformats.schemas.wordprocessingml.x2006.main.CommentsDocument;
//
//import javax.xml.namespace.QName;
//import java.io.IOException;
//import java.io.OutputStream;
//
//import static org.apache.poi.ooxml.POIXMLTypeLoader.DEFAULT_XML_OPTIONS;
//
//public class XWPFCommentsPart extends POIXMLDocumentPart {
//
//    private CTComments comments;
//
//    public XWPFCommentsPart(PackagePart commentPart) {
//        super(commentPart);
//        comments = CommentsDocument.Factory.newInstance().addNewComments();
//    }
//
//    public XWPFCommentsPart(PackagePart commentPart, CTComment[] olds) {
//        super(commentPart);
//        comments = CommentsDocument.Factory.newInstance().addNewComments();
//        if (olds!=null && olds.length!=0) {
//            CTComment[] news = new CTComment[olds.length];
//            System.arraycopy(olds, 0, news, 0, news.length);
//            comments.setCommentArray(news);
//        }
//    }
//
//    public CTComments getComments() {
//        return comments;
//    }
//
//    @Override
//    protected void commit() throws IOException {
//        System.out.println("XWPFCommentsPart: 保存批注");
//        XmlOptions xmlOptions = new XmlOptions(DEFAULT_XML_OPTIONS);
//        xmlOptions.setSaveSyntheticDocumentElement(
//                new QName(CTComments.type.getName().getNamespaceURI(), "comments"));
//        PackagePart part = getPackagePart();
//        OutputStream out = part.getOutputStream();
//        comments.save(out, xmlOptions);
//        out.close();
//    }
//}
